//
//  LogisticsDetailViewController.m
//  shuiyun
//
//  Created by edz on 2017/9/7.
//  Copyright © 2017年 qianyi. All rights reserved.
//

#import "LogisticsDetailViewController.h"
//#import "LogisticsMLViewController.h"
#import "LogisticsTableViewCell.h"
#import "MLDetailTableViewCell.h"
#import "UserCommentTableViewCell.h"

@interface LogisticsDetailViewController ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) NSMutableArray *dataArr;

@end

@implementation LogisticsDetailViewController



- (void)viewDidLoad {
    [super viewDidLoad];
    [self creationView];
    [self regeditCell];
    [self setTitle:@"名录详情"];
    self.view.backgroundColor = [UIColor blackColor];
    
    //
    UILabel *lab = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, DEF_SCREEN_WIDTH, 40)];
    lab.text = @"发布信息：2017/ 07/ 27/  15:33";
    lab.font = [UIFont systemFontOfSize:14];
    lab.textAlignment = NSTextAlignmentCenter;
    lab.backgroundColor = [UIColor whiteColor];
    lab.textColor = [UIColor colorWithRed:102/255.0f green:102/255.0f blue:102/255.0f alpha:1];
    [self.view addSubview:lab];
    
    //--------------背景颜色
    UIView *bottomView = [[UIView alloc]init];
    [self.view addSubview:bottomView];
    [bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view).offset(0);
        make.right.equalTo(self.view).offset(0);
        make.bottom.equalTo(self.view).offset(0);
        make.height.offset(40);
        
    }];
    bottomView.backgroundColor = [UIColor colorWithRed:245/255.0f green:245/255.0f blue:245/255.0f alpha:1];
    
    
    
    //---------------文本框
    UITextField *field = [[UITextField alloc] init];
    [bottomView addSubview:field];
    field.placeholder = @" 说点什么吧......";

    [field mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(bottomView).offset(16);
        make.bottom.equalTo(bottomView).offset(-5);
        make.height.offset(30);
        make.width.offset(300);
        
    }];
    field.backgroundColor = [UIColor colorWithRed:245/255.0f green:245/255.0f blue:245/255.0f alpha:1];
    
    //--------------发送按钮
    UIButton *buttonOut = [UIButton buttonWithType:UIButtonTypeCustom];
    [bottomView addSubview:buttonOut];
    [buttonOut mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(bottomView).offset(-16);
        make.bottom.equalTo(bottomView).offset(-5);
        make.height.offset(30);
        make.width.offset(50);
    }];
    [buttonOut setTitle:@"发送" forState:UIControlStateNormal];
    buttonOut.backgroundColor = [UIColor colorWithRed:63/255.0f green:135/255.0f blue:246/255.0f alpha:1];
    buttonOut.layer.cornerRadius = 5.0;
    buttonOut.layer.masksToBounds = YES;

    [buttonOut setTitleColor:getColor(@"FFFFFF") forState:UIControlStateNormal];
    [buttonOut addTarget:self action:@selector(btn) forControlEvents:UIControlEventTouchUpInside];
    
}

- (void)btn{
    
}

- (void)creationView{
    
    self.tableView = [[UITableView alloc] init];
    self.tableView.frame = CGRectMake(0, 40, DEF_SCREEN_WIDTH, DEF_SCREEN_HEIGHT - 64 - 40 - 40);
    self.tableView.tableFooterView = [[UITableView alloc] initWithFrame:CGRectZero];
    
    self.tableView.backgroundColor = [UIColor whiteColor];
    self.tableView.separatorStyle = UITableViewCellAccessoryNone;//去掉分割线
    self.tableView.estimatedRowHeight = 800;
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    [self.view addSubview:self.tableView];
    
}


- (void)regeditCell{
    
    [self.tableView registerNib:[UINib nibWithNibName:@"MLDetailTableViewCell" bundle:nil] forCellReuseIdentifier:@"MLDetailTableViewCell"];
    [self.tableView registerNib:[UINib nibWithNibName:@"UserCommentTableViewCell" bundle:nil] forCellReuseIdentifier:@"UserCommentTableViewCell"];
    
}

#pragma mark - ---------- Section的数量 ----------
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}
#pragma mark - ---------- 每个Section的高度 ----------
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 0;
}
//section 不随tableView滑动
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
    
    if (scrollView == self.tableView)
        
    {
        
        CGFloat sectionHeaderHeight = 64; //header高度
        
        if (scrollView.contentOffset.y <= sectionHeaderHeight && scrollView.contentOffset.y >= 0) {
            
            scrollView.contentInset = UIEdgeInsetsMake(-scrollView.contentOffset.y, 0, 0, 0);
            
        } else if (scrollView.contentOffset.y >= sectionHeaderHeight) {
            
            scrollView.contentInset = UIEdgeInsetsMake(-sectionHeaderHeight, 0, 0, 0);
            
        }
        
    }
    
    
    
}
#pragma mark - ---------- Cell的数量 ----------
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    
    return 10;
    
    
}

#pragma mark - ---------- 每个Cell的高度 ----------
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    if (indexPath.row == 0) {
        return 220;
    }else {
        
        return UITableViewAutomaticDimension;
    }
    
}
#pragma mark - ---------- 每个Cell的内容 ----------
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    if (indexPath.row == 0) {
        
        MLDetailTableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:@"MLDetailTableViewCell" forIndexPath:indexPath];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        
        return cell;
        
    }else {
        
        UserCommentTableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:@"UserCommentTableViewCell" forIndexPath:indexPath];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        
        return cell;
        
        
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
